package com.example.demo.Controller;

import com.example.demo.Dao.UserMaper;
import com.example.demo.Model.UserEntity;
import com.example.demo.Service.CallBackResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.SQLException;
import java.util.ArrayList;

@RestController
public class RegisterController {
    @Autowired
    private UserMaper userMaper;

    @RequestMapping(value ="/register",method = RequestMethod.POST)
    @ResponseBody
    public CallBackResult register(@RequestBody UserEntity user) {
        UserEntity userEntity=userMaper.findbyAccount(user.getAccont());
        if (userEntity!=null){
            return new CallBackResult("用户已存在","error",500);
        }
        else
        {
            userMaper.insertUser(user);
            return new CallBackResult("注册成功","success",200);
        }

    }
}